package com.tbh.ioc.bean;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * 通过注解获取Bean时，需要写上bean的value
 */
@Service("helloWorld")
@Component("helloWorld")
@Configuration("helloWorld")
public class HelloWorld {

    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * 生命周期：初始化
     */
    public void init() {
        System.out.println("Bean is going through init.");
    }

    /**
     * 生命周期：销毁
     */
    public void destroy() {
        System.out.println("Bean will destroy now.");
    }
}
